<template>
      <div>
            <home-header :city="city"></home-header>
            <home-swiper :swiper="swiper"></home-swiper>
            <home-icons :icons="icons"></home-icons>
            <home-other :hotJd="hotJd" :yLike="yLike"></home-other>
            <home-week :week="week"></home-week>
            <home-footer></home-footer>
      </div>
</template>

<script>
    /*引入组件*/
    import HomeHeader from '@/pages/home/components/Header'
    import HomeSwiper from '@/pages/home/components/Swiper'
    import HomeIcons from '@/pages/home/components/Icons'
    import HomeOther from '@/pages/home/components/Other'
    import HomeWeek from '@/pages/home/components/Week'
    import HomeFooter from '@/pages/home/components/Footer'
    import axios from 'axios'
    export default {
      name: "Home",
      data (){
          return {
             city: "", //hedder的数据
             swiper: [],  //轮播图的数据
             icons: [], //icons的数据
             hotJd: [], //热门榜单的数据
             yLike: [], //猜你喜欢的数据
             week: [] //周末去哪儿的数据
          }
      },
      components: { //注册组件
        HomeHeader,
        HomeSwiper,
        HomeIcons,
        HomeOther,
        HomeWeek,
        HomeFooter
      },
      methods: {
          getHomeInfo (){
             axios.get("/static/moke/index.json").then(this.getSucc);
          },
          getSucc (res) {
             res = res.data;
             if(res.ret && res.data){
                const data = res.data;
                this.city = data.city;
                this.swiper = data.swiperList;
                this.icons = data.iconList;
                this.hotJd = data.hotJd;
                this.yLike = data.yLike;
                this.week = data.WeekList;
             }
          }
      },
      mounted (){ //一般向后台请求数据并做一些业务处理
          this.getHomeInfo();
      }
    }
</script>

<style scoped>

</style>
